<!DOCTYPE html>
<html>
<head>
   <title>CSS Animations - animation: inherit</title>
   <link rel="author" title="Opera Software ASA" href="http://www.opera.com/">
   <link rel="help" href="http://dev.w3.org/csswg/css3-animations/#the-animation-shorthand-property-">
   <meta name="flags" content="dom">
   <meta name="assert" content="The 'inherit' value of 'animation' causes each
   corresponding longhand to inherit">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <style type="text/css">
      @keyframes grow {
         from {
            width: 100px;
         }
         to {
            width: 200px;
         }
      }
      div {
         width: 100px;
         height: 100px;
         background: red;
      }
      div > div {
         background: blue;
         animation: inherit;
      }
      .test {
         animation-duration: 0.6s;
         animation-iteration-count: 2;
         animation-direction: alternate;
         animation-delay: 300ms;
         animation-name: grow;
      }
   </style>
   <script type="text/javascript">
      setup({explicit_done:true});
      onload = function() {
         var testName = document.querySelector('title').firstChild.data;
         var divs = document.querySelectorAll('div');
         var log = document.querySelectorAll('p')[1].firstChild;
         function aboutEqual(observed, actual) {
            var maxDeviation = 100;
            return (Math.abs(observed - actual) < maxDeviation);
         }
         var timeout = setTimeout(function() {
            test(function(){assert_true(false);}, testName); done();
            log.data = 'FAIL';
         }, 2000);
         divs[1].addEventListener('animationend', function() {
            clearTimeout(timeout);
            var s = getComputedStyle(divs[1], null);
            var passed = (aboutEqual(Date.now() - startTime, 1500)
               && s.getPropertyValue('animation-name') == 'grow'
               && s.getPropertyValue('animation-duration') == '0.6s'
               && s.getPropertyValue('animation-iteration-count') == '2'
               && s.getPropertyValue('animation-direction') == 'alternate'
               && s.getPropertyValue('animation-delay') == '0.3s');
            test(function(){assert_true(passed);}, testName); done();
            log.data = (passed ? 'PASS if the animation occurred.' : 'FAIL');
         });
         var startTime = Date.now();
         divs[0].className = 'test';
      }
   </script>
   <style>iframe{display:none}</style>
</head>
<body>
   <p>The blue square below should grow into a rectangle twice as wide and then
   shrink back to its initial size, and there should be no red.</p>
   <p>Testing...</p>
   <div>
      <div></div>
   </div>
</body>
</html>
